import { getCollect } from '@/api/console'

const console1 = {
  state: {
    indexData: []
    // newdata: {} // 设备的最新温度
  },
  mutations: {
    GZEZTCOLLECT: (state, data) => {
      state.indexData = [{
        name: '分站总量',
        icon: 'icon iconfont icon-tubiao23',
        count: data.station,
        span: 6
      }, {
        icon: 'icon iconfont icon-wendubaojing',
        name: '测温设备总量',
        count: data.equipment,
        span: 6
      }, {
        name: '今日警报次数',
        icon: 'icon iconfont icon-baojing',
        count: data.push,
        span: 6
      }, {
        name: '实时最高温度',
        icon: 'icon iconfont icon-wenduji',
        count: data.monitor,
        span: 6
      }]
    }
    // GETNEW: (state, data) => {
    //   console.log(data)
    //   state.newdata = data.content
    // }
  },
  actions: {
    // 获取各数据总量
    getData({ commit }) {
      return new Promise((resolve, reject) => {
        getCollect().then((res) => {
          commit('GZEZTCOLLECT', res.content)
          resolve(res)
        }).catch(error => {
          reject(error)
        })
      })
    },
   // 获取所有检测设备的最新温度
    newTemper({ commit }) {
      // return new Promise((resolve, reject) => {
      //   console.log('``````````res``````````')
      //   getNew().then((res) => {
      //     console.log('``````````res``````````')
      //     console.log(res)
      //     commit('GETNEW', res)
      //     resolve(res)
      //   }).catch(error => {
      //     reject(error)
      //   })
      // })
    }
  }
}
export default console1
